package com.lhj.crm.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhj.crm.entity.Permission;
import com.lhj.crm.mapper.PermissionMapper;
import com.lhj.crm.service.IPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author FYI
 * @since 2020-03-23
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {
    @Autowired
    PermissionMapper permissionMapper;

    @Override
    public IPage<Permission> selectPermissionList(Page<Permission> page) {
        return permissionMapper.selectPermissionList(page);
    }

    @Override
    public Integer add(Permission permission) {
        permission.setCreateTime(new Date());
        permission.setUpdateTime(permission.getCreateTime());  //获取创建时间，可以提高一点性能
        permission.setIsDel(0);
        int insert = permissionMapper.insert(permission);
        return insert;
    }

    @Override
    public Integer update(Permission permission) {
        permission.setCreateTime(new Date());
        permission.setUpdateTime(permission.getCreateTime());  //获取创建时间，可以提高一点性能
        permission.setIsDel(0);
        int i = permissionMapper.updateById(permission);
        return i;
    }
}
